package com.demo.study.base.demos;

import org.junit.jupiter.api.Test;
import org.openjdk.jol.vm.VM;

/**
 * @author baymax
 * @since 2025-06-27
 */
public class Demo5_DateType {
    @Test
    public void test1() {
        byte a = 'a';
        byte b = 97;
        System.out.println(a); // 97
        System.out.println(b); // 97

        char c = 'a';
        char d = 97;
        System.out.println(c); // a
        System.out.println(d); // a

        short e = 'a';
        short f = 97;
        System.out.println(e); // 97
        System.out.println(f); // 97
    }

    @Test
    public void test2() {
        // 位数
        System.out.println(Byte.SIZE); // 8 一个byte占1个字节 1Byte
        System.out.println(Short.SIZE); // 16 一个short占2个字节 2Byte
        System.out.println(Integer.SIZE); // 32 一个int占4个字节 4Byte
        System.out.println(Long.SIZE); // 64 一个long占8个字节 8Byte
        System.out.println(Float.SIZE); // 32
        System.out.println(Double.SIZE); // 64
        System.out.println(Character.SIZE); // 16 一个字符占两个字节 2Byte
    }

    @Test
    public void test3() {
        int m1 = 1024 * 1024;
        int g1 = 1024 * 1024 * 1024;
        byte[] bytes = new byte[m1]; // 1M
        System.out.println(bytes.length);

        byte[] bytes1 = new byte[g1];
        byte[] bytes2 = new byte[g1];
    }

    @Test
    public void test4() {
        String str = "a";
        System.out.println(VM.current().sizeOfField(str));
    }

}
